from drg_group.yinchuan_2023.Base import message,intersect,SS_VALID
from drg_group.yinchuan_2023.DRG import MDCD_DRG

def group(record):
  adrg_zd=["C03.000x002","C03.100","C03.900","C31.000","C41.011","C41.100","D16.400x018","D16.406","D16.407","D16.411","D16.500","K01.000","K04.500","K04.501","K04.801","K04.802","K06.803","K06.901","K07.006","K07.100x017","K07.107","K07.108","K07.901","K07.902","K09.000x005","K09.004","K09.100x006","K09.204","K09.205","K10.103","K10.202","K10.204","K10.209","K10.800x005","K10.805","K10.900x002","K10.901","K12.202","K12.204","K12.217","S02.400x001","S02.400x003","S02.400x005","S02.401","S02.600","S02.600x011","S02.600x081","S02.600x091","S02.812","S03.000","Z42.006"]
  adrg_zd1=[]
  adrg_ss=["01.6x00","76.0101","76.0900x003","76.0900x004","76.0904","76.2x00x014","76.2x01","76.2x02","76.2x04","76.3100x001","76.3103","76.3104","76.3902","76.4300x003","76.4502","76.5x00","76.6300","76.6400x016","76.6401","76.6402","76.6500x006","76.6501","76.6502","76.6600","76.6800x002","76.6901","76.6904","76.7200","76.7200x001","76.7201","76.7401","76.7601","76.7602","76.7700","76.9200x004","76.9200x011","76.9300","76.9701"]
  adrg_ss1=[]
  adrg_ss2=[]
  dept_list=[]
  if True and record.zdList[0] in adrg_zd and record.ssList and record.ssList[0] in adrg_ss and record.ssList and intersect(record.ssList,adrg_ss):
    message('符合DG2入组条件，匹配规则：主诊断匹配、主手术匹配、某一手术匹配')
    
    if MDCD_DRG.DG29_group(record):
      return 'DG29'

    return 'DG2'
  else:
    return ''

